﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using SVC.client;
namespace UI.Forms
{
    public partial class Select_BC_forClient : DevExpress.XtraEditors.XtraForm
    {
        public delegate void DoAction(SVC.client.Cards card);//如果有参数的话，定义参数 
        public DoAction FatherRefresh;
        BindingList<Cards_Select> casl;
        private string kcid = "";
        private Guid? clientid = null;
        private string goodscode = "";
        /// <summary>
        /// 仓库ID
        /// </summary>
        /// <param name="kcid"></param>
        public Select_BC_forClient(string _kcid,Guid _clientid,string _goodscode)
        {
            InitializeComponent();
            kcid = _kcid;
            clientid = _clientid;
            goodscode = _goodscode;
        }

        private void Select_BC_Load(object sender, EventArgs e)
        {
            
        }

        private void bind()
        {
            if (radioGroup1.EditValue == null) return;
            rle_GoodCode.DataSource = my.bw.View_Goods_Lite_List("", my.ACID);
            rle_GoodCode.DisplayMember = "GoodsName";
            rle_GoodCode.ValueMember = "GoodsCode";
            BindingList<SVC.client.Cards> cas=null;
            if (Convert.ToBoolean(radioGroup1.EditValue))
            {
               cas = my.bw.Get_BlankCards_ck(kcid, goodscode, my.ACID);
            }
            else
            {
                cas = my.bw.Get_BlankCards_ClientID(clientid.Value, goodscode, my.ACID);
            }
             

            gridControl1.DataSource = cas;
        }

        private void btn_sx_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            bind();
        }

        private void btn_OK_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (gridView1.FocusedRowHandle<0 )return;
            SVC.client.Cards card = gridView1.GetRow(gridView1.FocusedRowHandle) as SVC.client.Cards;
            FatherRefresh(card);
            this.Close();
        }

        private void radioGroup1_SelectedIndexChanged(object sender, EventArgs e)
        {
            bind();
        }


    }
}